package com.liuguangaop.convert;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import pojo.User;

/**
 * @ClassName: MyConvertTest
 * @Description：
 * @Author: wanghr
 * Date: 6:53 PM 2020/7/13
 * Version: 1.0
 */
@Slf4j
@Component
public class MyConvertTest implements Converter<String, User> {
    @Override
    public User convert(String source) {
        log.info("进入自定义的转换参数方法");
        String[] split = source.split("_");
        String name = split[0];
        User user = new User();
        user.setName(name);
        user.setDes(split[1]);
        return user;
    }
}
